package com.ruoyi.common.enums;


import com.ruoyi.common.constant.RoleConstants;

/**
 * 平台默认的角色，对应的 roleId
 */
public enum RoleIdEnum {
    // 超级管理员
    SUPER_ADMIN(RoleConstants.ROLE_NAME_SUPER_ADMIN,1L),
    // 个人用户
    PERSONAL(RoleConstants.ROLE_NAME_PERSONAL,2L),
    // 企业用户
    COMPANY_ACCOUNT_OWNER(RoleConstants.ROLE_NAME_COMPANY_ACCOUNT_OWNER,3L),
    // 系统管理员
    COMAPNY_ADMIN(RoleConstants.ROLE_NAME_COMAPNY_ADMIN,4L),
    // 检测员
    INSPECTOR(RoleConstants.ROLE_NAME_INSPECTOR,5L);


    private String roleName;
    private Long roleId;

    RoleIdEnum(String roleName, Long roleId) {
        this.roleName = roleName;
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }


    public static Long getRoleId(String roleName){
        RoleIdEnum[] roleIdEnums = values();
        for (int i = 0; i < roleIdEnums.length; i++) {
            RoleIdEnum roleIdEnum = roleIdEnums[i];
            if (roleIdEnum.getRoleName().equals(roleName)) {
                return roleIdEnum.getRoleId();
            }
        }
        return null;
    }

}
